#include "cworker_cfg.h"

int cworker_cfg_init(cworker_cfg_t *cfg) {
    cfg->port = -1;
    return 0;
}

int cworker_cfg_clean(cworker_cfg_t *cfg) {
    return 0;
}

int cworker_cfg_update_local(cworker_cfg_t *cfg, wtk_local_cfg_t *main) {
    int ret = -1;

    wtk_string_t *v;
    wtk_local_cfg_t *lc;

    wtk_local_cfg_update_cfg_i(main, cfg, port, v);

    lc = wtk_local_cfg_find_lc_s(main, "log");
    if (lc) {
        ret = wtk_log_cfg_update_local(&(cfg->log), lc);
        if (ret) goto end;
    }

    lc = wtk_local_cfg_find_lc_s(main, "redis");
    if (lc) {
        ret = cworker_redis_cfg_update_local(&(cfg->redis), lc);
        if (ret) goto end;
    }

    lc = wtk_local_cfg_find_lc_s(main, "scripts");
    if (lc) {
        ret = cworker_script_cfg_update_local(&(cfg->scripts), lc);
        if (ret) goto end;
    }

    ret = 0;
end:
    return ret;
}

int cworker_cfg_update(cworker_cfg_t *cfg) {
    return 0;
}
